package com.cygia.springbootserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cygia.springbootserver.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 分页查询 Mysql Limit 1,10 从数据库表第一条开始，查询10条数据，
     *
     * @param offset
     * @param pageSize
     * @return
     */
    @Select("select * from user limit #{offset},#{pageSize} ")
    List<User> findByPage(Integer offset, Integer pageSize);

    @Select("select * from user where username like #{search} limit #{offset},#{pageSize} ")
    List<User> findByPage(Integer offset, Integer pageSize, String search);

    /**
     * 统计用户表总数量
     *
     * @return
     */
    @Select("select count(id) from user")
    Integer countUser();
}
